package logic

import (
	"context"
	"ewaimai/waimairpc/models"

	"ewaimai/waimairpc/internal/svc"
	"ewaimai/waimairpc/waimairpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUploadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUploadLogic {
	return &UserUploadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserUploadLogic) UserUpload(in *waimairpc.UseruploadRequest) (*waimairpc.UseruploadResponse, error) {
	// todo: add your logic here and delete this line
	var p models.User
	p.Image = in.Image
	p.Nickname = in.Nickname
	p.Tel = in.Tel
	if err := p.Create(); err != nil {
		logx.Errorf("用户上传成功")
	}
	return &waimairpc.UseruploadResponse{
		Id: int64(p.ID),
	}, nil
}
